package cn.com.demo.microservice.anquan.mapper;

import cn.com.demo.microservice.entity.AqAccount;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface AqAccountMapper {
    @Delete({
        "delete from aq_account",
        "where acc_id = #{accId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer accId);

    @Insert({
        "insert into aq_account (acc_id, acc_code, ",
        "acc_password, acc_slat, ",
        "acc_status, acc_ur_id)",
        "values (#{accId,jdbcType=INTEGER}, #{accCode,jdbcType=VARCHAR}, ",
        "#{accPassword,jdbcType=VARCHAR}, #{accSlat,jdbcType=VARCHAR}, ",
        "#{accStatus,jdbcType=INTEGER}, #{accUrId,jdbcType=INTEGER})"
    })
    int insert(AqAccount record);

    @InsertProvider(type=AqAccountSqlProvider.class, method="insertSelective")
    int insertSelective(AqAccount record);

    @Select({
        "select",
        "acc_id, acc_code, acc_password, acc_slat, acc_status, acc_ur_id",
        "from aq_account",
        "where acc_id = #{accId,jdbcType=INTEGER}"
    })
    @Results(id="AccountMapper",value={
        @Result(column="acc_id", property="accId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="acc_code", property="accCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="acc_password", property="accPassword", jdbcType=JdbcType.VARCHAR),
        @Result(column="acc_slat", property="accSlat", jdbcType=JdbcType.VARCHAR),
        @Result(column="acc_status", property="accStatus", jdbcType=JdbcType.INTEGER),
        @Result(column="acc_ur_id", property="accUrId", jdbcType=JdbcType.INTEGER)
    })
    AqAccount selectByPrimaryKey(Integer accId);

    @UpdateProvider(type=AqAccountSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AqAccount record);

    @Update({
        "update aq_account",
        "set acc_code = #{accCode,jdbcType=VARCHAR},",
          "acc_password = #{accPassword,jdbcType=VARCHAR},",
          "acc_slat = #{accSlat,jdbcType=VARCHAR},",
          "acc_status = #{accStatus,jdbcType=INTEGER},",
          "acc_ur_id = #{accUrId,jdbcType=INTEGER}",
        "where acc_id = #{accId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(AqAccount record);

    @ResultMap("AccountMapper")
    @Select("select * from aq_account where acc_code=#{accCode}")
    AqAccount selectByCode(String username);
}